@inject('request','Illuminate\Http\Request')
@inject('pictureService','App\Interfaces\PictureService')
@inject('orderService','App\Interfaces\OrderService')
@inject('refundGoodsService','App\Interfaces\RefundGoodsService')

@if($orders->total())

    @foreach($orders as $key=>$order)

   		            <?php

   			            $pay_type = 1;

   			            switch ($order->pay_type) {

   			            	case 'alipay':

   			            		$pay_type = 1;

   			            		break;

   			            	case 'wxpay':

   			            		$pay_type = 3;

   			            		break;

   			            	case 'pinganpay':

   			            		$pay_type = 4;

   			            		break;

   			            	default:

   			            		$pay_type = 1;

   			            		break;
   			            }
   		            ?>
   	                <div class="ui-my-order ui-border-tb">
   	                    <div class="ui-my-order-header">
   	                        <div class="title">
   	                            订单号：{{$order->order_sn}}
   	                        </div>
   	                        <div class="del">
   	                            @if($order->order_status==4 || $order->order_status==5)
   	                            <i class="ui-icon-delete J-delete" data-id="{{$order->order_id}}"></i>
   	                            @endif
   	                        </div>
   	                        <div class="status">
   	                            @if($order->order_status==1)
   	                                <span class="text-color-7">
   	                                待支付
   	                                </span><br>
   	                            @elseif($order->order_status==2)
   	                                <span class="text-color-7">
   	                                待发货
   	                                </span><br>
   	                            @elseif($order->order_status==3)
   	                                <span class="text-color-1">待收货</span><br>

   	                            @elseif($order->order_status==4 && $order->comment_status==0)
   	                                <span class="text-color-7">
                                       @if(@$request->condations['order_status'] && @$request->condations['order_status']=='4')
                                           待评价
                                       @else
                                          已评价
                                       @endif
   	                                </span><br>
                                   @elseif($order->order_status==4 && $order->comment_status==1)
                                       <span class="text-color-7">
                                       @if(@$request->condations['order_status'] && @$request->condations['order_status']=='4')
                                           待评价
                                       @else
                                          已评价
                                       @endif
                                       </span><br>
   	                            @elseif($order->order_status==5)
   	                                <span class="text-color-7">
   	                                已取消
   	                                </span><br>
                                   @elseif($order->order_status==6)
                                       <span class="text-color-7">
                                       已退款
                                       </span><br>
   	                            @endif
   	                        </div>
   	                    </div>

   	                    <div class="ui-my-order-content">
   	                        <ul class="ui-list ui-border-tb" onclick="window.location.href='/my/order/{{$order->order_id}}'">

                                <?php 

                                       /*$goodsList=$orderService->getOrderGoods($order->order_id); 
                                       $goodsCount=$goodsList->count(); */

                                       $goodsList = $order->order_goods;
                                       $goodsCount = count($goodsList); 

                                   ?>

   			                    @foreach($goodsList as $orderGoodskey=>$orderGoods)

   			                    <?php $notLast= ($orderGoodskey+1 < $goodsCount); ?>

                               	<li class="ui-border-t">
   	                                <div class="ui-list-img">
                                          <span style="background-image:url({{$pictureService::thumb($orderGoods['goods_thumb'], 70, 70)}})"></span>
   	                                </div>
   	                                <div class="ui-list-info">
                                          <h4 class="ui-nowrap">{{$orderGoods['goods_name']}}</h4>
                                          <h4>×{{$orderGoods['buy_number']}}</h4>

   	                                </div>

   	                            </li>
   	            				@endforeach

   	                        </ul>
   	                    </div>
   	                    <div class="ui-my-order-footer">共{{ $goodsCount }}件商品    实付款:   <font class="ui-font-red">¥{{$order->pay_price}}</font></div>
   	                    <div class="ui-my-order-toolbar ui-border-t">
   	                        <div class="ui-btn-wrap">

   	                            @if($order->order_status==1)
   		                            <button class="ui-btn-s J-cancelOrder" data-id="{{$order->order_id}}">
   		                                取消
   		                            </button>
   		                            <button class="ui-btn-s ui-btn-danger" data-id="{{$order->order_id}}" onclick="window.location.href='/pay/request/{{$order->order_id}}/{{$pay_type}}'">
   		                                支付
   		                            </button>
   	                            @elseif($order->order_status==2)
   	                            	<button class="ui-btn-s ui-btn-default J-payagain" data-id="{{$order->order_id}}" data-goCart="true">再次购买</button>
   	                            @elseif($order->order_status==3)
   	                            	<button class="ui-btn-s ui-btn-default J-receive" data-id="{{$order->order_id}}">确认收货</button>

   	                            @elseif($order->order_status==4)

   	                            	@if(!@$request->condations['refund_goods'])

   		                                @if($order->comment_status==0)
   			                            <button data-href="/comment?order_id={{$order->order_id}}" class="ui-btn-s ui-btn-default" data-id="{{$order->order_id}}">
   			                                评价
   			                            </button>
   		                                @elseif($order->comment_status==1)
   		                                <button class="ui-btn-s ui-btn-gray" >已评价</button>
   		                                @endif

   	                                @endif
   	                            	<button class="ui-btn-s ui-btn-default J-payagain" data-id="{{$order->order_id}}" data-goCart="true">再次购买</button>
   	                            @elseif($order->order_status==5)
   	                                <!-- <a  class="ui-btn-s ui-btn-payagain ui-btn-default" data-id="{{$order->order_id}}" data-goCart="true" href="javascript:;">再次购买</a> -->
   	                            	<button class="ui-btn-s ui-btn-default J-payagain" data-id="{{$order->order_id}}" data-goCart="true">再次购买</button>
   	                            @endif
   	                            <button class="ui-btn-s ui-btn-default" data-id="{{$order->order_id}}" onclick="window.location.href='/my/order/{{$order->order_id}}'">
   	                                订单详情
   	                            </button>
   	                        </div>
   	                    </div>
   	                </div>

   	            @endforeach

@else
        <div class="ui-loading-wrap">
            <p>别拉了 到底了！</p>
        </div>
@endif
